.class public final Lcom/burstly/lib/component/ComponentFactory;
.super Ljava/lang/Object;
.source "ComponentFactory.java"


# static fields
.field private static final BURSTLY_ADAPTOR_FACTORY:Ljava/lang/String; = "com.burstly.lib.component.networkcomponent.burstly.BurstlyAdaptorFactory"

.field private static final BURSTLY_IMAGE:Ljava/lang/String; = "BURSTLY_IMAGE"

.field private static final BURSTLY_SCRIPT:Ljava/lang/String; = "BURSTLY_SCRIPT"

.field private static final BURSTLY_TEXT:Ljava/lang/String; = "BURSTLY_TEXT"

.field private static final BURSTLY_VIDEO:Ljava/lang/String; = "BURSTLY_VIDEO"

.field private static final BURSTLY_VIEW_ID:Ljava/lang/ThreadLocal; = null
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ThreadLocal",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private static final CURRENT_NETWORK_NAME:Ljava/lang/ThreadLocal; = null
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ThreadLocal",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private static final FACTORY_CLASS:Ljava/lang/String; = "factoryClass"

.field private static final LOG:Lcom/burstly/lib/util/LoggerExt;

.field private static final LOG_TAG:Ljava/lang/ThreadLocal;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ThreadLocal",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 46
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/component/ComponentFactory;->LOG:Lcom/burstly/lib/util/LoggerExt;

    .line 51
    new-instance v0, Ljava/lang/ThreadLocal;

    invoke-direct {v0}, Ljava/lang/ThreadLocal;-><init>()V

    sput-object v0, Lcom/burstly/lib/component/ComponentFactory;->CURRENT_NETWORK_NAME:Ljava/lang/ThreadLocal;

    .line 56
    new-instance v0, Ljava/lang/ThreadLocal;

    invoke-direct {v0}, Ljava/lang/ThreadLocal;-><init>()V

    sput-object v0, Lcom/burstly/lib/component/ComponentFactory;->BURSTLY_VIEW_ID:Ljava/lang/ThreadLocal;

    .line 61
    new-instance v0, Ljava/lang/ThreadLocal;

    invoke-direct {v0}, Ljava/lang/ThreadLocal;-><init>()V

    sput-object v0, Lcom/burstly/lib/component/ComponentFactory;->LOG_TAG:Ljava/lang/ThreadLocal;

    return-void
.end method

.method private constructor <init>()V
    .locals 0

    .prologue
    .line 91
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 93
    return-void
.end method

.method private static createBurstlyQueueElement(Ljava/lang/String;Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)Lcom/burstly/lib/component/ComponentQueueElement;
    .locals 6
    .parameter "burstlyViewId"
    .parameter "rData"

    .prologue
    .line 183
    const/4 v1, 0x0

    .line 184
    .local v1, key:Ljava/lang/String;
    invoke-static {p1}, Lcom/burstly/lib/util/Utils;->isSimpleText(Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)Z

    move-result v2

    if-nez v2, :cond_0

    invoke-static {p1}, Lcom/burstly/lib/util/Utils;->isTextImage(Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)Z

    move-result v2

    if-eqz v2, :cond_2

    .line 185
    :cond_0
    const-string v1, "BURSTLY_TEXT"

    .line 193
    :cond_1
    :goto_0
    if-eqz v1, :cond_5

    .line 194
    new-instance v0, Lcom/burstly/lib/component/BurstlyComponentQueueElement;

    const-string v2, "com.burstly.lib.component.networkcomponent.burstly.BurstlyAdaptorFactory"

    invoke-direct {v0, p0, v1, v2}, Lcom/burstly/lib/component/BurstlyComponentQueueElement;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 196
    .local v0, bcqe:Lcom/burstly/lib/component/BurstlyComponentQueueElement;
    const-string v2, "burstly"

    invoke-virtual {v0, v2}, Lcom/burstly/lib/component/BurstlyComponentQueueElement;->setFactoryId(Ljava/lang/String;)V

    .line 200
    .end local v0           #bcqe:Lcom/burstly/lib/component/BurstlyComponentQueueElement;
    :goto_1
    return-object v0

    .line 186
    :cond_2
    invoke-static {p1}, Lcom/burstly/lib/util/Utils;->isBanner(Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)Z

    move-result v2

    if-eqz v2, :cond_3

    .line 187
    const-string v1, "BURSTLY_IMAGE"

    goto :goto_0

    .line 188
    :cond_3
    invoke-static {p1}, Lcom/burstly/lib/util/Utils;->isScript(Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)Z

    move-result v2

    if-eqz v2, :cond_4

    .line 189
    const-string v1, "BURSTLY_SCRIPT"

    goto :goto_0

    .line 190
    :cond_4
    invoke-static {p1}, Lcom/burstly/lib/util/Utils;->isVideo(Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)Z

    move-result v2

    if-eqz v2, :cond_1

    .line 191
    const-string v1, "BURSTLY_VIDEO"

    goto :goto_0

    .line 199
    :cond_5
    sget-object v3, Lcom/burstly/lib/component/ComponentFactory;->LOG:Lcom/burstly/lib/util/LoggerExt;

    sget-object v2, Lcom/burstly/lib/component/ComponentFactory;->LOG_TAG:Ljava/lang/ThreadLocal;

    invoke-virtual {v2}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    const-string v4, "Unsupported Burstly ad."

    const/4 v5, 0x0

    new-array v5, v5, [Ljava/lang/Object;

    invoke-virtual {v3, v2, v4, v5}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 200
    const/4 v0, 0x0

    goto :goto_1
.end method

.method private static createThirdPartyQueueElement(Ljava/lang/String;Ljava/lang/String;)Lcom/burstly/lib/component/ComponentQueueElement;
    .locals 5
    .parameter "burstlyViewId"
    .parameter "responseParams"

    .prologue
    .line 212
    const/4 v1, 0x0

    .line 213
    .local v1, className:Ljava/lang/String;
    invoke-static {p1}, Lcom/burstly/lib/util/Utils;->get3rdPartySdkName(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 214
    .local v0, adaptorName:Ljava/lang/String;
    sget-object v3, Lcom/burstly/lib/component/ComponentFactory;->CURRENT_NETWORK_NAME:Ljava/lang/ThreadLocal;

    invoke-virtual {v3, v0}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V

    .line 215
    const-string v3, "factoryClass"

    invoke-virtual {p1, v3}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v3

    const/4 v4, -0x1

    if-eq v3, v4, :cond_0

    .line 217
    invoke-static {p1}, Lcom/burstly/lib/util/Utils;->get3rdPartySdkParams(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

    invoke-static {v3}, Lcom/burstly/lib/util/Utils;->fromJson(Ljava/lang/String;)Lcom/burstly/lib/network/ResponseObject;

    move-result-object v2

    .line 218
    .local v2, rObj:Lcom/burstly/lib/network/ResponseObject;
    const-string v3, "factoryClass"

    invoke-virtual {v2, v3}, Lcom/burstly/lib/network/ResponseObject;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    .end local v1           #className:Ljava/lang/String;
    check-cast v1, Ljava/lang/String;

    .line 223
    .end local v2           #rObj:Lcom/burstly/lib/network/ResponseObject;
    .restart local v1       #className:Ljava/lang/String;
    :goto_0
    new-instance v3, Lcom/burstly/lib/component/ComponentQueueElement;

    invoke-direct {v3, p0, v0, v1}, Lcom/burstly/lib/component/ComponentQueueElement;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    return-object v3

    .line 221
    :cond_0
    invoke-static {v0}, Lcom/burstly/lib/util/Utils;->extractFactoryClassName(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    goto :goto_0
.end method

.method public static getComponents(Landroid/content/Context;Ljava/lang/String;Lcom/burstly/lib/network/beans/ResponseBean;Lcom/burstly/lib/network/beans/RequestData;)Ljava/util/Collection;
    .locals 1
    .parameter "context"
    .parameter "burstlyViewId"
    .parameter "response"
    .parameter "request"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/content/Context;",
            "Ljava/lang/String;",
            "Lcom/burstly/lib/network/beans/ResponseBean;",
            "Lcom/burstly/lib/network/beans/RequestData;",
            ")",
            "Ljava/util/Collection",
            "<",
            "Lcom/burstly/lib/component/ComponentQueueElement;",
            ">;"
        }
    .end annotation

    .prologue
    .line 106
    invoke-static {p1}, Lcom/burstly/lib/component/ComponentFactory;->setLogTag(Ljava/lang/String;)V

    .line 107
    invoke-static {p0, p1, p2, p3}, Lcom/burstly/lib/component/ComponentFactory;->getSpecificComponents(Landroid/content/Context;Ljava/lang/String;Lcom/burstly/lib/network/beans/ResponseBean;Lcom/burstly/lib/network/beans/RequestData;)Ljava/util/Collection;

    move-result-object v0

    return-object v0
.end method

.method private static getSpecificComponents(Landroid/content/Context;Ljava/lang/String;Lcom/burstly/lib/network/beans/ResponseBean;Lcom/burstly/lib/network/beans/RequestData;)Ljava/util/Collection;
    .locals 14
    .parameter "context"
    .parameter "burstlyViewId"
    .parameter "response"
    .parameter "request"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/content/Context;",
            "Ljava/lang/String;",
            "Lcom/burstly/lib/network/beans/ResponseBean;",
            "Lcom/burstly/lib/network/beans/RequestData;",
            ")",
            "Ljava/util/Collection",
            "<",
            "Lcom/burstly/lib/component/ComponentQueueElement;",
            ">;"
        }
    .end annotation

    .prologue
    .line 121
    new-instance v4, Ljava/util/ArrayList;

    invoke-direct {v4}, Ljava/util/ArrayList;-><init>()V

    .line 122
    .local v4, components:Ljava/util/Collection;,"Ljava/util/Collection<Lcom/burstly/lib/component/ComponentQueueElement;>;"
    const/4 v3, 0x0

    .line 123
    .local v3, component:Lcom/burstly/lib/component/ComponentQueueElement;
    invoke-virtual/range {p2 .. p2}, Lcom/burstly/lib/network/beans/ResponseBean;->getData()[Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;

    move-result-object v5

    .line 124
    .local v5, data:[Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;
    if-eqz v5, :cond_2

    array-length v8, v5

    if-lez v8, :cond_2

    .line 125
    move-object v1, v5

    .local v1, arr$:[Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;
    array-length v7, v1

    .local v7, len$:I
    const/4 v6, 0x0

    .local v6, i$:I
    :goto_0
    if-ge v6, v7, :cond_3

    aget-object v2, v1, v6

    .line 126
    .local v2, cData:Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;
    invoke-static {v2}, Lcom/burstly/lib/component/ComponentFactory;->setExpirationTime(Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)V

    .line 127
    invoke-static {v2}, Lcom/burstly/lib/util/Utils;->isThirdPartySDK(Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)Z

    move-result v8

    if-eqz v8, :cond_0

    .line 128
    invoke-virtual {v2}, Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;->getParms()Ljava/lang/String;

    move-result-object v8

    invoke-static {p1, v8}, Lcom/burstly/lib/component/ComponentFactory;->createThirdPartyQueueElement(Ljava/lang/String;Ljava/lang/String;)Lcom/burstly/lib/component/ComponentQueueElement;

    move-result-object v3

    .line 132
    :goto_1
    if-eqz v3, :cond_1

    .line 133
    invoke-virtual {v3, v2}, Lcom/burstly/lib/component/ComponentQueueElement;->setCreativeData(Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)V

    .line 134
    move-object/from16 v0, p2

    invoke-virtual {v3, v0}, Lcom/burstly/lib/component/ComponentQueueElement;->setFullResponse(Lcom/burstly/lib/network/beans/ResponseBean;)V

    .line 135
    move-object/from16 v0, p3

    invoke-virtual {v3, v0}, Lcom/burstly/lib/component/ComponentQueueElement;->setFullRequest(Lcom/burstly/lib/network/beans/RequestData;)V

    .line 136
    invoke-interface {v4, v3}, Ljava/util/Collection;->add(Ljava/lang/Object;)Z

    .line 137
    const/4 v3, 0x0

    .line 125
    :goto_2
    add-int/lit8 v6, v6, 0x1

    goto :goto_0

    .line 130
    :cond_0
    invoke-static {p1, v2}, Lcom/burstly/lib/component/ComponentFactory;->createBurstlyQueueElement(Ljava/lang/String;Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)Lcom/burstly/lib/component/ComponentQueueElement;

    move-result-object v3

    goto :goto_1

    .line 139
    :cond_1
    sget-object v9, Lcom/burstly/lib/component/ComponentFactory;->LOG:Lcom/burstly/lib/util/LoggerExt;

    sget-object v8, Lcom/burstly/lib/component/ComponentFactory;->LOG_TAG:Ljava/lang/ThreadLocal;

    invoke-virtual {v8}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;

    move-result-object v8

    check-cast v8, Ljava/lang/String;

    const-string v10, "{0} is an unsupported network!"

    const/4 v11, 0x1

    new-array v11, v11, [Ljava/lang/Object;

    const/4 v12, 0x0

    sget-object v13, Lcom/burstly/lib/component/ComponentFactory;->CURRENT_NETWORK_NAME:Ljava/lang/ThreadLocal;

    invoke-virtual {v13}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;

    move-result-object v13

    aput-object v13, v11, v12

    invoke-virtual {v9, v8, v10, v11}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_2

    .line 143
    .end local v1           #arr$:[Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;
    .end local v2           #cData:Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;
    .end local v6           #i$:I
    .end local v7           #len$:I
    :cond_2
    sget-object v9, Lcom/burstly/lib/component/ComponentFactory;->LOG:Lcom/burstly/lib/util/LoggerExt;

    sget-object v8, Lcom/burstly/lib/component/ComponentFactory;->LOG_TAG:Ljava/lang/ThreadLocal;

    invoke-virtual {v8}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;

    move-result-object v8

    check-cast v8, Ljava/lang/String;

    const-string v10, "No Ads available..."

    const/4 v11, 0x0

    new-array v11, v11, [Ljava/lang/Object;

    invoke-virtual {v9, v8, v10, v11}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 145
    :cond_3
    return-object v4
.end method

.method private static minutesToMillisec(Ljava/lang/Integer;)J
    .locals 2
    .parameter "ttl"

    .prologue
    .line 172
    invoke-virtual {p0}, Ljava/lang/Integer;->intValue()I

    move-result v0

    mul-int/lit8 v0, v0, 0x3c

    mul-int/lit16 v0, v0, 0x3e8

    int-to-long v0, v0

    return-wide v0
.end method

.method private static setExpirationTime(Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;)V
    .locals 9
    .parameter "rData"

    .prologue
    .line 154
    invoke-virtual {p0}, Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;->getExpires()Ljava/lang/Integer;

    move-result-object v0

    .line 155
    .local v0, ttl:Ljava/lang/Integer;
    if-eqz v0, :cond_0

    invoke-virtual {p0}, Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;->getExpiresAfter()Ljava/lang/Long;

    move-result-object v1

    if-nez v1, :cond_0

    .line 156
    invoke-static {v0}, Lcom/burstly/lib/component/ComponentFactory;->minutesToMillisec(Ljava/lang/Integer;)J

    move-result-wide v1

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v3

    add-long/2addr v1, v3

    invoke-static {v1, v2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v1

    invoke-virtual {p0, v1}, Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;->setExpiresAfter(Ljava/lang/Long;)V

    .line 158
    :cond_0
    invoke-virtual {p0}, Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;->getExpiresAfter()Ljava/lang/Long;

    move-result-object v1

    if-eqz v1, :cond_1

    .line 159
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getLogLevel()I

    move-result v1

    const/4 v2, 0x3

    if-ne v1, v2, :cond_1

    .line 160
    sget-object v2, Lcom/burstly/lib/component/ComponentFactory;->LOG:Lcom/burstly/lib/util/LoggerExt;

    sget-object v1, Lcom/burstly/lib/component/ComponentFactory;->LOG_TAG:Ljava/lang/ThreadLocal;

    invoke-virtual {v1}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/lang/String;

    const-string v3, "Ad expires at {0} {1}"

    const/4 v4, 0x2

    new-array v4, v4, [Ljava/lang/Object;

    const/4 v5, 0x0

    new-instance v6, Ljava/util/Date;

    invoke-virtual {p0}, Lcom/burstly/lib/network/beans/ResponseBean$ResponseData;->getExpiresAfter()Ljava/lang/Long;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/Long;->longValue()J

    move-result-wide v7

    invoke-direct {v6, v7, v8}, Ljava/util/Date;-><init>(J)V

    aput-object v6, v4, v5

    const/4 v5, 0x1

    aput-object p0, v4, v5

    invoke-virtual {v2, v1, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 163
    :cond_1
    return-void
.end method

.method private static setLogTag(Ljava/lang/String;)V
    .locals 4
    .parameter "burstlyViewId"

    .prologue
    .line 232
    sget-object v0, Lcom/burstly/lib/component/ComponentFactory;->BURSTLY_VIEW_ID:Ljava/lang/ThreadLocal;

    invoke-virtual {v0, p0}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V

    .line 233
    sget-object v0, Lcom/burstly/lib/component/ComponentFactory;->LOG_TAG:Ljava/lang/ThreadLocal;

    const-string v1, "ComponentFactory for {0}"

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    aput-object p0, v2, v3

    invoke-static {v1, v2}, Ljava/text/MessageFormat;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/ThreadLocal;->set(Ljava/lang/Object;)V

    .line 234
    return-void
.end method
